﻿namespace Digitalmes.Common.Exceptions;

/// <summary>
/// 表示为业务异常。
/// </summary>
public class BusinessException : Exception
{
    public int? Code { get; set; }

    public string? Details { get; set; }

    public BusinessException(int? code = null,
        string? message = null,
        string? details = null, 
        Exception? innerException = null) : base(message, innerException)
    {
        Code = code;
        Details = details;
    }

    public BusinessException WithData(string name, object value)
    {
        Data[name] = value;
        return this;
    }
}
